package cn.edu.neusoft.model.bean;

import lombok.Data;
import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest;

import java.util.List;

@Data
public class CarInfo {
    private int id;
    private String carCode;
    private String carNum;
    private String carNumColor;
    private String carType;
    private String carBrand;
    private String carColor;
    private String carStatus;
    private int ownerId;
    private String ownerName;
    private String ownerCode;
    private int parkType;
    private int listType;
    private long createTime;
    private int createUser;
    private long updateTime;
    //VO
    private int departmentId;
    private int departmentType;
    private String departmentName;

    public CarInfo(Car car) {
        this.id = car.getId();
        this.carCode = car.getCarCode();
        this.carNum = car.getCarNum();
        this.carNumColor = car.getCarNumColor();
        this.carType = car.getCarType();
        this.carBrand = car.getCarBrand();
        this.carColor = car.getCarColor();
        this.carStatus = car.getCarStatus();
        this.ownerId = car.getOwnerId();
        this.ownerName = car.getOwnerName();
        this.ownerCode = car.getOwnerCode();
        this.departmentId = car.getDepartmentId();
        this.parkType = car.getParkType();
        this.listType = car.getListType();
        this.createTime = car.getCreateTime();
        this.createUser = car.getCreateUser();
        this.updateTime = car.getUpdateTime();

        // 检查 personDepartmentListVO 列表是否为空，并且至少有一个元素
        if (car.getPersonDepartmentListVO() != null && !car.getPersonDepartmentListVO().isEmpty()) {
            this.departmentType = car.getPersonDepartmentListVO().get(0).getDepartmentType();
            this.departmentName = car.getPersonDepartmentListVO().get(0).getDepartmentName();
        }
    }
}
